<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('积分记录列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <p class="select-title">当前积分：【<span th:text="${credit}"></span>】</p>
            <form id="balance-record-form">
                <input type="hidden" name="memberId" th:value="${memberId}"/>
                <div class="select-list">
                    <ul>
                        <!--<li>-->
                            <!--<p style="width: 110px">流水号： </p>-->
                            <!--<input type="text" name="recordSn"/>-->
                        <!--</li>-->
                        <!--<li>-->
                            <!--<p style="width: 110px">流水类型： </p>-->
                            <!--<select name="type" th:with="type=${@dict.getType('credit_record_type')}">-->
                                <!--<option value="-1">全部</option>-->
                                <!--<option th:each="dict : ${type}" th:text="${dict.dictLabel}"-->
                                        <!--th:value="${dict.dictValue}"></option>-->
                            <!--</select>-->
                        <!--</li>-->
                        <li>
                            <p style="width: 110px">关联模块： </p>
                            <select name="linkModel" th:with="type=${@dict.getType('link_model')}">
                                <option value="-1">全部</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <!--<li>-->
                            <!--<p style="width: 110px">关联单号： </p>-->
                            <!--<input type="text" name="linkSn"/>-->
                        <!--</li>-->
                        <li class="select-time">
                            <p style="width: 110px">记录时间： </p>
                            <input type="text" class="time-input" style="width: 150px;" data-type="datetime"
                                   placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" style="width: 150px;" data-type="datetime"
                                   placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "back/shopMember";

    const typeDict = [[${@dict.getType('balance_record_type')}]];
    const linkModelDict = [[${@dict.getType('link_model')}]];

    $(function () {
        var options = {
            url: prefix + "/searchCreditRecordList",
            modalName: "积分记录",
            sortName: "createTime",
            sortOrder: "desc",
            columns: [
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'recordSn',
                    title: '流水号',
                    sortable: true,
                    visible: false
                },
                {
                    field: 'type',
                    title: '流水类型',
                    sortable: true,
                    visible: false,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(typeDict, value);
                    }

                },
                {
                    field: 'linkModel',
                    title: '关联模块',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(linkModelDict, value);
                    }
                },
                {
                    field: 'linkSn',
                    title: '关联单号',
                    visible: false,
                    sortable: true
                },
                {
                    field: 'oldCredit',
                    title: '变动前积分',
                    sortable: true,
                    formatter: function (value, item, index) {
                        return '<span class="badge badge-warning">' + value + '</span>';
                    }
                },
                {
                    field: 'changeCredit',
                    title: '积分变动',
                    sortable: true,
                    formatter: function (value, item, index) {
                        switch (item.changeType) {
                            case 0:
                                return '<span class="badge badge-danger">+' + value + '</span>';
                            case 1:
                                return '<span class="badge badge-primary">' + value + '</span>';
                            default:
                                return '-';
                        }
                    }
                },
                {
                    field: 'newCredit',
                    title: '变动后积分',
                    sortable: true,
                    formatter: function (value, item, index) {
                        return '<span class="badge badge-info">' + value + '</span>';
                    }
                },
                {
                    field: 'remark',
                    title: '备注',
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>